﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebUI.Infrastructure;
using Utils;
using WebUI.Utils;

namespace WebUI.Controllers
{
    public class JobController : BaseController
    {
        [HttpPost]
        [Authorize]
        public JsonResult Save(int jobID)
        {
            try
            {
                SqlUtilities.Execute(ConstUtils.SP_InsertSavedJob, new { IdentityWithoutUserName.LoginID, jobID }, null, true);
                return Json(JsonResultModelHelper.ForSuccess());
            }
            catch
            {
                return Json(JsonResultModelHelper.ForError());
            }
        }

        [HttpPost]
        [Authorize]
        public JsonResult Unsave(int jobID)
        {
            try
            {
                SqlUtilities.Execute(ConstUtils.SP_DeleteSavedJob, new { IdentityWithoutUserName.LoginID, jobID }, null, true);
                return Json(JsonResultModelHelper.ForSuccess());
            }
            catch
            {
                return Json(JsonResultModelHelper.ForError());
            }
        }

    }
}
